// 购物车路由
const router = require('express').Router();

// 导入控制器
const { addFn, getList, del: delCon, upSel: upSelCon, subCon } = require('../controllers/carts');
// 导入中间件
const { add: addM, list: listM, del: delM, upSel: upSelM, subM,tokenTest } = require('../middleware/carts');


// 购物车路由中直接使用tokenTest 中间件
router.use(tokenTest);

// 添加购物车
router.post('/add', addM, addFn);

// 获取购物车列表
router.get('/list', listM, getList);

// 删除购物车数据
router.post('/del', delM, delCon);

// 修改选中状态
router.get('/updateSel', upSelM, upSelCon);

// 减少购物车商品数量
router.get('/sub', subM, subCon);


module.exports = router;